<div class="easyui-panel" title="学生管理" data-options="fit:true" style="display: flex;flex-direction: column;" >
	<p style="flex-grow: 0;">
		<label>选择班级：</label>
		<input class="easyui-combobox" data-options="
			url:'banji/list',
			valueField:'id',
			textField:'name',
			panelHeight:200,
			editable:false,
			icons:[{
				iconCls:'icon-clear',
				handler:function(e){
					$(e.data.target).textbox('clear');
					$('#div').hide();
				}
			}],
			onChange:function(id){
				var grid=$('#stugrid');
				var options=grid.datagrid('options');
				options.url='student/page?classId='+id;
				options.dialog.add.href='student/edit?classId='+id;
				options.dialog.edit.href='student/edit?classId='+id;
				$('#div').show();
				grid.datagrid(options);
			}
		" />
	</p>
	<div id="div" style="flex-grow: 1; display: none; ">
		<table id="stugrid">
			<thead>
				<tr>
					<th data-options="checkbox:true,field:'asd'">sdsd</th>
					<th data-options="field:'id', hidden:true  ">ID</th>
					<th width="250" data-options="field:'className'">班级</th>
					<th width="200" data-options="field:'stuNo'" >学号</th>
					<th width="200" data-options="field:'name'">姓名</th>
				</tr>
			</thead>
		</table>
	</div>
</div>
<script type="text/javascript">

		var grid=$('#stugrid');
		grid.datagrid({
			idField:'id',
			url:'student/page',
			fit:true,
			singleSelect:true,
			fitColumns:true,
			autoRowHeight:true,
			//striped:true,
			idField:'id',
			sortName:'id',
			sortOrder:'asc',
			pagination:true,
			pageList:[5,10,25,50],
 			toolbar:[$.crudgrid.buttons.add,"-",$.crudgrid.buttons.edit,"-",$.crudgrid.buttons.remove,"-",$.crudgrid.buttons.search
 				,"-",{
 	 			iconCls:'icon-filter',
 	 			text:'浏览照片',
				handler:function(){
					var grid=$.crudgrid.grid(this);
					var row = grid.datagrid('getSelected');
					if(!row){
						$.messager.alert('提示','请选择一行数据，在进行此操作....','warning');
						return;
					}
					$.post('student/photo',{id:row.id},function(){
						var dialog = $('<div style="display:none;"/>');
						dialog.appendTo($('body'));
						var img = $('<img/>');
						img.attr('src', 'student/download?id=' + row.id);
						img.attr('width', '100%');
						dialog.append(img);
						dialog.dialog({
							autoOpen: true,
							title: '图片显示',
							modal: true,
							width: 400,
							close: function(e, ui) {
								dialog.dialog('destroy');
								dialog.remove();
							}

						})
					})
				
/* 					$.post('student/photo',{id:row.id},function(result){
						
					}) */
				}
 	 			},"-",{
				iconCls:'icon-redo',
				text:'密码重置',
				handler:function(){
					var grid=$.crudgrid.grid(this);
					var row = grid.datagrid('getSelected');
					if(!row){
						$.messager.alert('提示','请选择一行数据，在进行此操作....','warning');
						return;
					}
					$.post('student/resetPwd',{id:row.id},function(result){
						$.messager.show({title:'提示',msg:result.msg});
					})
				}
			},"-",
			$.crudgrid.buttons.refresh,"-"],
			dialog:{
				add:{
					title:'新增',
					href:'student/edit',
					action:'student/save'
				}, 
				edit:{
					title:'修改',
					href:'student/edit',
					action:'student/save'
				},
				search:{
					title:'查询',
					href:'student/search'
				},
				remove:{
					url:'student/delete',
					msg:'是否要删除这条记录？'
				}
			} 			
		})

</script>